package com.tdrc.common.controller;

import com.tdrc.common.beans.Menu;
import com.tdrc.common.beans.Unit;
import com.tdrc.common.service.MenuService;
import com.tdrc.common.service.UnitService;
import com.tdrc.common.util.JsonResult;
import com.tdrc.common.beans.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author dpf
 * @version 1.0
 * @date 2020-4-3 11:18
 * @instruction ...
 */
@RestController
@RequestMapping("/unit")
public class UnitController {
    @Resource
    private UnitService unitService;
    @Value("${general.parameter.topUnitId}")
    private int topUnitId;

    @PostMapping("/add")
    public Object add(@RequestBody Unit unit){
        return new JsonResult(ResultCode.OK);
    }

    @GetMapping("/treeUnit")
    public Object treeUnit() {
        return new JsonResult(ResultCode.OK, unitService.treeUnit(topUnitId));
    }
    @GetMapping("/listUnit")
    public Object listUnit() {
        return new JsonResult(ResultCode.OK, unitService.listUnit());
    }

}
